﻿using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using System.IO;

namespace Bootstrap.Admin
{
    /// <summary>
    /// 
    /// </summary>
    public class Program
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            //CreateWebHostBuilder(args).Build().Run();

            IConfiguration configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("hosting.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables()
                .Build();

            BuildWebHost(args, configuration).Run();

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args).UseSentry().UseStartup<Startup>();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IWebHost BuildWebHost(string[] args, IConfiguration configuration)
        {
            return WebHost.CreateDefaultBuilder(args).UseConfiguration(configuration).UseContentRoot(Directory.GetCurrentDirectory()).UseStartup<Startup>().Build();
        }


    }
}
